package com.gxuwz.core.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.gxuwz.core.model.Page;
import com.gxuwz.core.pagination.QueryFilter;

/**
 * 
 * Data Access Object (DAO) interface.   This is an interface
 * used to tag our DAO classes and to provide common methods to all DAOs.
 *
 */

public interface BaseDao<T> {
	
	  /**
	   * 
	   * @param entity
	   * @return
	   */
	  public  T save(T entity);
	  /**
	   * 
	   * @param entity
	   * @return
	   */
	  public  T merge(T entity);
	  /**
	   * 
	   * @param entity
	   */
	  public  void update(T entity);
	  /**
	   * 
	   * @param clazz
	   * @param id
	   * @return
	   */
	  public  T get(Class<T> clazz,Serializable id);
	  /**
	   * 
	   * @param clazz
	   * @param id
	   */
	  public  void remove(Class <T> clazz,Serializable id);
	  /**
	   * 
	   * @param entity
	   */
	  public  void remove(T entity);
	  /**
	   * 
	   * @return
	   */
	  public  List<T> getAll(String clazz);
	  /**
	   * 
	   * @param queryString
	   * @param params
	   * @return
	   */
	  public  List<T> findByHql(String queryString, Object[] params);
	  /**
	   * 根据实体类查询数据
	   * @param exampleEntity
	   * @return
	   */
	  public List<T> findByExample(Object exampleEntity);
	  /**
	   * 根据实体类查询分页数据
	   * @param exampleEntity
	   * @param firstResult
	   * @param maxResults
	   * @return
	   */
	  public List<T> findByExample(Object exampleEntity, int firstResult, int  maxResults);
	  
	  /**
	   * Remove the given object from the Session cache
	   * @param entity
	   */
	  public  void evict(T entity);
	  /**
	   * 
	   */
	  public  void flush();
	  
	  public List<T> find(String hql);

	  public List<T> findByEntity(T entity);
	  
	  public Page getPage(T entity, Integer page, Integer limit);
	}
